<?php

function bdd_insert($bdd, $table, $values) {

// INSERT 	INTO Eleves(code_eleve, nom_eleve, prenom_eleve, genre_eleve, civilite_eleve, date_naissance_eleve, login_eleve, libelle_classe_eleve) 
	// VALUES 	("","nom1","prenom1","Z","Dr","1999-09-09", "", "classe1"), 
		// ("","nom2","prenom2","Y","Mgr","1996-06-06", "", "classe2");

	$pdo_i = connexion_Table($bdd, $table); 

	$sql_i = 'INSERT 	INTO '.$table; 
	// $sql_i .= ' VALUES ("99911","nom1","prenom1","Z","Dr","1999-09-09", "", "classe1"), ("99922","nom2","prenom2","Y","Mgr","1996-06-06", "", "classe2");';
	$sql_i .= ' VALUES ' . $values;
		
	echo "<br>Requete SQL : $sql_i<br>";
	$nb_i = $pdo_i->exec($sql_i);
	echo "<br>Nombre d'enregistrements inserés : " . $nb_i ." ! <br>";
			
}

function bdd_update($bdd, $table, $set, $where_id) {

// UPDATE 	Groupes 
	// SET libelle_xml_groupe="il_grp_7a4"
	// WHERE id_groupe=9

	$pdo_u = connexion_Table($bdd, $table); 

	$sql_u = 'UPDATE '.$table; 
	// $sql_u .= ' SET genre_eleve="Z"';
	$sql_u .= ' SET ' . $set;
	// $sql_u .= ' WHERE code_eleve="99922"';
	$sql_u .= ' WHERE ' . $where_id;
	
	echo "<br>Requete SQL : $sql_u<br>";
	$nb_u = $pdo_u->exec($sql_u);
	echo "<br>Nombre d'enregistrements mis-à-jour : " . $nb_u ." ! <br>";	
	
}

function bdd_delete($bdd, $table, $where_id_in) {

// DELETE FROM Groupes 
	// WHERE id_groupe IN (8,9)

	$pdo_d = connexion_Table($bdd, $table); 

	$sql_d = 'DELETE FROM '.$table; 
	// $sql_d .= ' WHERE code_eleve =' .$where_id_in; 
	$sql_d .= ' WHERE ' . $where_id_in;
	
	echo "<br>Requete SQL : $sql_d<br>";
	$nb_d = $pdo_d->exec($sql_d);
	echo "<br>Nombre d'enregistrements effacés : " . $nb_d ." ! <br>";
	
}

?>